<template>
	<view>
		<view class="box" v-if="false">
			<button @click="toaddress">点击新增地址</button>
		</view>
		<view class="bom" v-else>

			<view class="boxx" v-for="(item,index) in list" :key="item.id">
				<view class="bol">
					<u-checkbox-group>
						<u-checkbox @change="confirm(index)" :checked="item.status==1?true:false">
						</u-checkbox>
					</u-checkbox-group>
				</view>
				<view class="boc" @click="confirm(index)">
					<view class="boc-t">
						<span>{{item.username}}</span> <span>{{item.userphone}}</span> <span>{{item.label}}</span>
					</view>
					<view class="boc-b">
						{{item.location+item.useraddress}}
					</view>
				</view>
				<view class="bor" @click="toaddress(item.id)">
					<u-icon name="edit-pen-fill" size="36"></u-icon>
				</view>
			</view>

			<view class="boxx aaa">
				<view class="box bbb">
					<button @click="toaddress">点击新增地址</button>
				</view>
			</view>


		</view>
	</view>
</template>

<script>
	import {
		addresslist
	} from '../../rquest/api.js'
	export default {
		data() {
			return {
				list: []
			}
		},
		onShow() {
			addresslist({
				uid: uni.getStorageSync("user").uid,
			}).then(res => {
				console.log(res);
				this.list = res.data.list
			})
		},
		methods: {
			toaddress(e) {
				uni.setStorageSync('backshow',e)
				uni.navigateTo({
					url: '../address/address'
				})
			},
			addchecked(e) {
				console.log(e);
			},
			confirm(e) {
				// console.log(e);
				this.list.map(item => {
					item.status = false
				})
				this.list[e].status = this.list[e].status==1?2:1
				uni.setStorageSync('dizhi',this.list[e])
				uni.navigateTo({
					url:'../order/order'
				})
			}
		}
	}
</script>

<style>
	.aaa {
		display: flex;
		justify-content: center;
		align-items: center;
		padding: 0px;
	}

	.bbb {
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		padding: 20rpx;
	}

	.aaa button {
		width: 100%;
	}

	.bol {
		padding: 10rpx;
		box-sizing: border-box;
	}

	.boxx {
		margin: 30rpx auto;
		display: flex;
		width: 90%;
		border-radius: 10rpx;
		background-color: #eee;
		padding: 20rpx;
		align-items: center;
		border-radius: 39rpx;

	}

	.bor {
		box-sizing: border-box;
		text-align: center;
	}

	.boc-t {
		font-weight: bold;
		display: flex;
		justify-content: left;
	}

	.boc-t span {
		display: block;
		margin-right: 30rpx;
	}

	.boc-t span:nth-child(3) {

		background-color: #FF6040;
		padding: 0px 10rpx;
		border-radius: 9rpx;
		color: #fff;

	}

	.boc {
		width: 80%;
		box-sizing: border-box;
		line-height: 60rpx;
	}

	.box button {
		width: 60%;
		background-color: #FF6040;
		color: #fff;
		margin-top: 139rpx;
	}

	.bbb button {
		margin-top: 0px;

		background-color: dodgerblue;
	}
</style>
